﻿using System.Collections.Generic;
using System.Data;
using MyFloridaHouse.DataAccess.Extensions;
using MyFloridaHouse.libSvDTO;
using System.Data.SqlClient;
using Microsoft.SqlServer.Types;

namespace MyFloridaHouse.DataAccess
{
    public partial class DAL_CensusData
    {
        /// <summary>
        /// Gets the district geography shape.
        /// </summary>
        /// <param name="iUogIDList">The i uog ID list.</param>
        /// <returns>List of <see cref="SqlGeography"/></returns>
        /// <remarks>SPROC: usp_GetGeographiesFromUogIDList</remarks>
        public List<SqlGeography> GetDistrictGeographyShape(string iUogIDList)
        {
            List<SqlGeography> itemList = new List<SqlGeography>();

            //string storedProcedureName = "usp_GetGeographiesFromUogIDList";
            string storedProcedureName = "usp_tl10GetGeographiesFromUogIDList10";

            using (SqlConnection db = Connect())
            {
                SqlCommand StoredProcedureCommand = new SqlCommand(storedProcedureName, db);
                StoredProcedureCommand.CommandType = CommandType.StoredProcedure;
                SqlParameter dataPartIDParm = StoredProcedureCommand.Parameters.AddWithValue("uogIDList", iUogIDList);
                dataPartIDParm.Direction = ParameterDirection.Input;

                db.Open();
                using (SqlDataReader rdr = StoredProcedureCommand.ExecuteReader())
                {
                    while (rdr.Read())
                    {
                        itemList.Add(DistrictShapeGeography_DataContract.DataContract(rdr));
                    }
                }
            }

            return itemList;
        }
    }
}
